import xlrd
import word_go
data = []

arr = []
#打开文件
wb = xlrd.open_workbook(r'var.xlsx')
#获取所有sheet的名字
#sheet1索引从0开始，得到sheet1表的句柄
sheet1 = wb.sheet_by_index(0)
rowNum = sheet1.nrows
colNum = sheet1.ncols
print(rowNum )
print(colNum)

#构建替换关系
i = 0
while i<colNum:
    print(sheet1.cell(0,i).value)
    data.append({'var':sheet1.cell(0,i).value})
    i=i+1
#s = sheet1.cell(1,0).value.encode('utf-8')
i = 0
j = 0
while i<rowNum:
    j=0
    temp ={}
    while j<colNum:
        temp[data[j]['var']]= sheet1.cell(i,j).value
        j=j+1
    print(temp)
    arr.append(temp)
    i=i+1
print(arr)
#获取某一个位置的数据

word_go.searchAndReplace(arr,sheet1.cell(0,0).value)